<?php
function send_forgot_email($email,$id,$config)
{
	$time = time();
	$rand = getrandnum(10);
	$forgot = md5($time.'_:_'.$rand.'_:_'.$email);
	
	mysql_query("UPDATE `".$config['db']['pre']."users` SET `forgot` = '".addslashes($forgot)."' WHERE `user_id` =".addslashes($id)." LIMIT 1 ;");

	require_once("includes/classes/class.phpmailer.php");
	
	$mail = new PHPMailer();
	
	IF($config['email']['type'] == 'smtp')
	{
		$mail->IsSMTP();
		$mail->SMTPAuth = true;
		$mail->Username = $config['email']['smtp']['user'];
		$mail->Password = $config['email']['smtp']['pass'];
		$mail->Host = $config['email']['smtp']['host'];
	}
	ELSEIF ($config['email']['type'] == 'sendmail')
	{
		$mail->IsSendmail();
	}
	ELSE
	{
		$mail->IsMail();
	}
	
	$mail->FromName = $config['site_title'];
	$mail->From = $config['admin_email'];
	$mail->AddAddress($email);
	
	$mail->Subject = $config['site_title'] . ": Forgot Password";
	$mail->Body = "To reset your password please click the link below:\n\n".$config['site_url']."login.php?forgot=".$forgot."&r=".$rand."&e=".$email."&t=".$time;
	$mail->IsHTML(false);
	$mail->Send();
}
?>